package Code.Basic.Entity;

import org.jrabbit.standard.game.graphics.skins.animation.AnimatedSkin;

import net.phys2d.math.Vector2f;
import net.phys2d.raw.shapes.ConvexPolygon;
import Code.Basic.World.PhysicsInfo;


public class GenericTerrain extends PhysicsSprite
{
	public GenericTerrain(String filepath, float[][] points, 
			double x, double y, double rotation)
	{
		super(filepath);
		defineBuilding(points);
		setLocation(x, y);
		setRotation(rotation);
		body.setMoveable(false);
		body.setRotatable(false);
	}
	
	public GenericTerrain(AnimatedSkin skin, float[][] points, 
			double x, double y, double rotation)
	{
		super(skin);
		defineBuilding(points);
		setLocation(x, y);
		setRotation(rotation);
		body.setMoveable(false);
		body.setRotatable(false);
	}
	
	public void defineBuilding(float[][] points)
	{
		Vector2f[] vectors = new Vector2f[points.length];
		for(int i = 0; i < vectors.length; i++)
		{
			vectors[i] = new Vector2f(points[i][0] / PhysicsInfo.SCALE, points[i][1] / PhysicsInfo.SCALE);
		}
		
		body.setShape(new ConvexPolygon(vectors));
	}
}
